﻿<%@ WebHandler Language="C#" Class="UpdateElement" %>

using System;
using System.Web;
using System.Linq;
public class UpdateElement : IHttpHandler {
    
    public void ProcessRequest (HttpContext context) {
        try
        {
            string parameter = context.Request.QueryString["para"];
            string value = context.Request.QueryString["value"];
            string username = context.Request.QueryString["key"];
            if (parameter != null && value != null && username != null)
            {
                using (Up1VNDataContext dc = new Up1VNDataContext())
                {
                    User U = dc.Users.Single(u => u.Users_Name == username);
                    switch (parameter)
                    {
                        case "Email":
                            U.Users_Email = value;
                            break;
                        case "Homephone":
                            U.Users_HomePhone = value;
                            break;
                        case "Mobile":
                            U.Users_MobilePhone = value;
                            break;
                        case "Yahoo":
                            U.Users_YahooNick = value;
                            break;
                        case "Skype":
                            U.Users_SkypeNick = value;
                            break;
                    }
                    dc.SubmitChanges();
                }
                context.Response.Write("1");
            }
            else
                context.Response.Write("0");
        }
        catch (Exception)
        {
            context.Response.Write("0");
        }
    }
    public bool IsReusable {
        get {
            return false;
        }
    }

}